package utils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @time: 2021/11/12/012 14:05
 * @author: Zhurunhe
 * @Version：1
 */
public class CalDayToDay {

    public static void main(String[] args) {
        System.out.println(caculateTotalTime("2021-11-12","2021-11-12","yyyy-MM-dd"));
    }
    public static int caculateTotalTime(String startTime, String endTime,String format) {
        SimpleDateFormat formatter = new SimpleDateFormat(format);
        Date date1 = null;
        Date date2 = null;
        Long l = 0L;
        try {
            date1 = formatter.parse(startTime);
            date2 = formatter.parse(endTime);
            l = (date2.getTime() - date1.getTime()) / (1000 * 60 * 60 * 24);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return l.intValue()+1;
    }
}
